<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php 

$host = "localhost";
$user = "root";
$passwd = "";
$database = "mysql";
 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
 mysql_query("SET character_set_results=utf8", $connect);
mysql_select_db($database); 


 		$kq=mysql_query("select count(*) from help_topic"); 
        $r=mysql_fetch_array($kq);
        $numrow=$r[0];		
        //số record cho 1 trang
        $pagesize=10;
        //Tính tổng số trang
        $pagecount=ceil($numrow/$pagesize);			
        //Xác định số trang cho mỗi lần hiển thị
        $segsize=5;
        //Thiết lập trang hiện hành
        if(!isset($_GET["page"]))
			 $curpage=1;
        else	
        	 $curpage=$_GET["page"];
        if($curpage<1)
			 $curpage=1;
        if($curpage>$pagecount) $curpage=$pagecount;
        //Xác định số phân đoạn của trang
        $numseg=($pagecount % $segsize==0)?($pagecount/$segsize):(int)($pagecount/$segsize+1);
        //Xác định phân đoạn hiện hành của trang
        $curseg=($curpage % $segsize==0)?($curpage/$segsize):(int)($curpage/$segsize+1);   
		$k=($curpage-1)*$pagesize;
		

        $sql3="select * from help_topic  limit $k,$pagesize";
		$kq3=mysql_query($sql3);
		while($r3=mysql_fetch_array($kq3))
		{

		$mota=$r3["name"];



?>
<div><?php echo $r3["help_topic_id"] ."--". $r3["name"];?>  <?php echo  $curseg; ?> <br /></div>
<?php } ?>
<?php 
if($curseg>1)
			echo "<a href='?m=sp&b=sp-list&page=".(($curseg-1)*$segsize)."'><b>Previous</b></a> &nbsp;";
			$n=$curseg*$segsize<=$pagecount?$curseg*$segsize:$pagecount;
			for($i=($curseg-1)*$segsize+1;$i<=$n;$i++)
			{
				if($curpage==$i)
					echo "<a href='?m=sp&b=sp-list&page=".$i."'><font color='blue'>[".$i."]</font></a> &nbsp;";
				else
					echo "<a href='?m=sp&b=sp-list&page=".$i."'><font color='blue;'>[".$i."]</font></a> &nbsp;";
			}
			if($curseg<$numseg)
			echo "<a href='?m=sp&b=sp-list&page=".(($curseg*$segsize)+1)."'><b>Next</b></a> &nbsp;";
			echo $n;	

?>

</body>
</html>